import Vue from 'vue'
import Vuex from 'vuex'

import { api, $api } from './api'

var querystring = require('querystring');
var remote = true;


Vue.use(Vuex)


const main = {
  state: {
    
  },
  mutations: {
    
  },
  actions: {
    login(context, payload) {
      return api('/api/login', {type:'post',params:payload})
    },
    
  }
}

const mySteps = {
  state: {
    current:0
  },
  mutations: {
    current(state,n){
      state.current=n
    },
    plusCurrent(state,n){
      state.current++
    },
    minusCurrent(state,n){
      state.current--
    }
  },
  actions: {
  }
}

const pickorder = {
  state: { 
  },
  mutations: {
  },
  actions: {
    unfinish(context, payload) {
      return api('/api/pickorder/unfinish')
    },
    audit_users(context,payload){
      return api('/api/pickorder/users')
    },
    detail(context, payload) {
      return api('/api/pickorder/detail',{params:payload})
    },   
    toaudit(context, payload) {
      return api('/api/pickorder/toaudit',{type:'post',params:payload})
    },   
    auditing(context, payload) {
      return api('/api/pickorder/auditing')
    }, 
    
    passlist(context, payload) {
      return api('/api/pickorder/passlist')
    },  
  }
}
const audit = {
  state: { 
  },
  mutations: {
  },
  actions: {
    auditList(context, payload) {
      return api('/api/audit')
    },    
    reject(context, payload) {
      return api('/api/audit/reject',{type:'post',params:payload})
    },
    pass(context, payload) {
      return api('/api/audit/pass',{type:'post',params:payload})
    },  
  }
}

const mallorder = {
  state: {    
  },
  mutations: {
  },
  actions: {
    saveInfo(context, payload) {
      return api('/api/mallorder/saveInfo',{type:"post",params:payload})
    },
    delInfo(context, payload) {
      return api('/api/mallorder/del',{type:"post",params:payload})
    },
   
  }
}
const user = {
  state: {    
  },
  mutations: {
  },
  actions: {
    userinfo(context, payload) {
      return api('/api/user/one',{type:"post",params:payload})
    },
    settings(context, payload) {
      return api('/api/user/settings',{type:"post",params:payload})
    },
   
  }
}
const report = {
  state: {    
  },
  mutations: {
  },
  actions: {
    reportIndex(context, payload) {
      return api('/api/report')
    },
    reportComp(context, payload) {
      return api('/api/report/comp',{params:payload})
    },
  }
}




const store = new Vuex.Store({
  modules: {
    main,
    mySteps,
    pickorder,
    mallorder,
    audit,
    user,
    report
  }
})

export default store